# coding=utf-8

import os
import asyncio

from wechaty import Wechaty
from server import start_server

os.environ['WECHATY_PUPPET_SERVICE_TOKEN'] = 'linrol'


async def main():
    bot = Wechaty()
    bot.on('scan', lambda status, qrcode, data: print('Scan QR Code to login: {}\nhttps://wechaty.js.org/qrcode/{}'.format(status, qrcode)))
    bot.on('login', lambda user: print('User {} logged in'.format(user)))

    await asyncio.gather(
        start_server(bot),
        bot.start()
    )

asyncio.run(main())
